/*
 * SimpleSpeaker.java
 * for test use
 * 
 * */

package wps.servicebus.client;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class SimpleSpeaker {	
	public static boolean sendMessage(String message, String addr, int port){
		Socket socket;
		try {
			socket = new Socket(addr, port);
			PrintWriter out = new PrintWriter(socket.getOutputStream(), true);			
			out.println(message);
			return true;
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
		
	}
	
	
	public static void main(String[] args) throws UnknownHostException, IOException{
		int port = 10001;
		sendMessage("check out...", "127.0.0.1", port);
//		sendMessage("quit,123", "127.0.0.1", port);		
	}
}
